﻿using System;

namespace calculator_a1
{
    class Program
    {
        static void Main(string[] args)
        {
            double result=0;
            bool haveError = false;
            while (true) { 

                Console.WriteLine("请输入第一个数字：");
                try
                {
                    string a1_s = Console.ReadLine();
                    double a1 = Convert.ToDouble(a1_s);
                    Console.WriteLine("请输入运算符：");
                    string op1 = Console.ReadLine();
                    Console.WriteLine("请输入第二个数字：");
                    string a2_s1 = Console.ReadLine();
                    double a2_1 = Convert.ToDouble(a2_s1);
                    switch (op1)
                    {
                        case "+":
                            result = a1 + a2_1;
                            break;
                        case "-":
                            result = a1 - a2_1;
                            break;
                        case "*":
                            result = a1 * a2_1;
                            break;
                        case "/":
                            if (a2_1 == 0)
                            {
                                haveError = true;
                                Console.WriteLine("错误，除数不能为0");
                            }
                            else
                            {
                                result = a1 / a2_1;
                            }
                            break;
                        default:
                            Console.WriteLine("错误");
                            haveError = true;
                            break;

                    }
                    if (!haveError)
                    {
                        Console.WriteLine("结果为:" + result);
                    }
                    else
                    {
                        haveError = false;
                    }
                }
                catch
                {
                    Console.WriteLine("输入错误");
                }
                
             
                Console.WriteLine("是否退出：1.继续 2.退出");
                string con = Console.ReadLine();
                if (con == "2")
                {
                    break;
                }
                
            }

        }
    }
}
